import request from '#/utils/requestAbort';

// 使用新服务的交易单元，黑龙江、陕西
export const useNewService = ['PDBLJ', 'PXBSX'];

// 查询省列表
// 没有用
export async function queryProvinceList(params) {
  return request(`/clearing-settlement/electricityCostSortManagement/getProvinceList`, {
    method: 'GET',
  });
}

// 表格查询
export async function statementInfoList(params) {
  const { marketId } = params;
  const url = `${
    useNewService.includes(marketId) ? '/private-business' : '/clearing-settlement'
  }/electricityCostSortManagement/getSortManagementList`;
  return request(url, {
    method: 'POST',
    data: params,
  });
}

// 操作日志
export async function logList(params, marketId) {
  const url = `${
    useNewService.includes(marketId) ? '/private-business' : '/clearing-settlement'
  }/electricityCostSortManagement/logList`;
  return request(url, {
    method: 'POST',
    data: params,
  });
}

// 新增
export function addElectricityDetailList(params) {
  const { marketId } = params;
  const url = `${
    useNewService.includes(marketId) ? '/private-business' : '/clearing-settlement'
  }/electricityCostSortManagement/add`;
  return request(url, {
    method: 'POST',
    data: params,
  });
}

// 删除
export function delElectricityDetailList(id, marketId) {
  if (useNewService.includes(marketId)) {
    return request('/private-business/electricityCostSortManagement/delete', {
      method: 'POST',
      data: {
        id,
        marketId,
      },
    });
  } else {
    return request(`/clearing-settlement/electricityCostSortManagement/delete/${id}`, {
      method: 'GET',
    });
  }
}

// 修改
export function editElectricityDetailList(params) {
  const { marketId } = params;
  const url = `${
    useNewService.includes(marketId) ? '/private-business' : '/clearing-settlement'
  }/electricityCostSortManagement/update`;
  return request(url, {
    method: 'POST',
    data: params,
  });
}

// 根据省份ID获取交易名称列表
export function getListStatementTypeByProvinceId(marketId) {
  const url = `${
    useNewService.includes(marketId) ? '/private-business' : '/clearing-settlement'
  }/electricityCostSortManagement/listStatementTypeByProvinceId/${marketId}`;
  return request(url, {
    method: 'GET',
  });
}

// 获取全部交易属性与数据类型
export function getListTransactionAttributes(marketId) {
  const url = `${
    useNewService.includes(marketId) ? '/private-business' : '/clearing-settlement'
  }/electricityCostSortManagement/listTransactionAttributes/${marketId}`;
  return request(url, {
    method: 'GET',
  });
}

// 导出
export async function exportList(params, marketId) {
  const url = `${
    useNewService.includes(marketId) ? '/private-business' : '/clearing-settlement'
  }/electricityCostSortManagement/export`;
  return request(url, {
    method: 'POST',
    responseType: 'blob',
    data: {
      idList: params,
      marketId,
    },
  });
}
